package collections.exercise;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class PokerDemo {

    public static void main(String[] args) {
        String[] types = {"红桃", "黑桃", "方片", "梅花"};
        String[] numbers = {"A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K"};

        List poker = new ArrayList();

        //初始化一副新扑克牌
        for (int i = 0; i < types.length; i++) {
            for (int j = 0; j < numbers.length; j++) {
                poker.add(types[i] + numbers[j]);
            }
        }

        System.out.println(poker);
        Collections.shuffle(poker);

        System.out.println("---------------洗完牌之后--------------");
        System.out.println(poker);

        //分别生成四个子集合，随机发个四个玩家。
        for (int i = 0; i < 4; i++) {
            List subList = poker.subList(i * 13, i * 13 + 13);
            System.out.println("第" + (i + 1) + "个玩家手中的牌是：" + subList);
        }
    }
}
